/*OWmq6Ugo6jPE4W7xoi1UXlXa6Uo/GAeDS7JN8mWOERFI1YSIxjzhvlCZGmRoUoRn*/
import { ajax, promptBox, toast } from 'nc-lightapp-front';

export default function afterEvent(props, moduleId, key, value, changedrows, i, s, g) {
    let data={
        key:null,
        date:null,
        pk_ratetype:null,
        pk_org:this.state.pk_org,
        pk_curr:this.state.m_sCurrency,
        ratedate:null
    }
    switch (key) {
        case 'pk_ratetype':
           this.state.pk_ratetype = value.value;
           if(value.value){
            data.key = 'pk_ratetype';
            data.date = this.state.m_sClrq;
            data.pk_ratetype = value.value;
            dobusiAjax(this,data,key);
           }  
        break;
        case 'm_sClrq':
        //    data.key = 'm_sClrq';
        //    data.date = value.value;
        //    data.pk_ratetype = this.state.pk_ratetype;
        //    dobusiAjax(this,data);
        break;
        case 'ratedate':
            if(value.value){
                data.key = 'ratedate';
                data.ratedate = value.value;
                data.pk_ratetype = this.state.pk_ratetype;
                dobusiAjax(this,data,key);
            }
         break;
        case 'm_sToObBm':
            //转入户
            let zrObject = props.form.getFormItemsValue("form", "m_izrWldx");
            if (zrObject.value == '0') {//如果转入对象是客户，需要判断同步转移订单客户参数
                props.setOrdercubAssign(value, 0);
            }
            break;

    }
    function dobusiAjax(that,data,key){
       // let field =['ratedate','m_dBbhl','pk_ratetype']
        ajax({
            url: '/nccloud/arap/debtransfer/afterchangeRateType.do',
            data: data,
            async: false,
            success: (res) => {
             if(res.data){
                that.state.ratedate = res.data.info.ratedate;
                let ratedateEdit = res.data.ratedateEdit;
                that.props.form.setFormItemsDisabled("form", {'ratedate':!ratedateEdit,'m_dBbhl':!ratedateEdit});
                if(key !='ratedate'){
                    that.props.form.setFormItemsValue("form", { 'ratedate': { value:   res.data.info.ratedate, display:   res.data.info.ratedate } });//后台有逻辑处理当编辑的是汇率日期的时候
                }
                that.props.form.setFormItemsValue("form", { 'm_dBbhl': { value:  res.data.info.rate, display:  res.data.info.rate } });
             }
            },
        });
    }
}


/*OWmq6Ugo6jPE4W7xoi1UXlXa6Uo/GAeDS7JN8mWOERFI1YSIxjzhvlCZGmRoUoRn*/